package axdoc.rule.check;

import java.lang.reflect.Field;

import com.alibaba.fastjson.JSONObject;

public abstract class AbsCheck implements Check {

	public String cname;

	@Override
	public String getCname() {
		return this.cname;
	}

	@Override
	public void setCname(String cname) {
		this.cname = cname;
	}

	@Override
	public boolean check(JSONObject json) {
		return false;
	}

	public void initValue(JSONObject json) {
		Field[] fields = this.getClass().getDeclaredFields();
		for (int i = 0; i < fields.length; i++) {
			String fieldName = fields[i].getName();
			try {
				fields[i].set(this, json.get(fieldName));
			} catch (IllegalArgumentException e1) {
				e1.printStackTrace();
			} catch (IllegalAccessException e1) {
				e1.printStackTrace();
			}
		}
	};

}
